#!/bin/sh

# BBEdit / TextWrangler HTML Tidy Script
# http://stackoverflow.com/questions/3018209/

# 1. Place into ~/Library/Application Support/BBEdit/Text Filters/
# 2. Quit and restart BBEdit
# 3. Select the text to format before running the script from the Script/Text menu

# tidy is built into Mac OS X
# See also http://tidy.sourceforge.net/docs/tidy_man.html
tidy -raw --clean 1 --drop-empty-paras 0 --fix-backslash 0 --hide-endtags 0 --merge-divs 0 --numeric-entities 1 --show-errors 0 --show-warnings 0 --tab-size 8 --indent 'auto' --indent-spaces 8 --wrap 0 --language 'en' --output-bom 0 --output-encoding 'raw' --force-output 1 --quiet 1 --tidy-mark 0 | unexpand

# Unknown options for Mac OS X version (2002-12-01)
# --merge-spans 0
# --preserve-entities 1
# --show-body-only 'auto'